package CreativePattern.BuilderPattern;

public class Computer {
    private String CPU;
    private String GPU;
    private int RAM;
    private int storage;
    private PeripheralDevice peripheralDevice;
    private Computer(){}
    @Override
    public String toString() {
        return "Computer " +
                "[CPU=" + CPU
                + ", GPU=" + GPU
                + ", RAM=" + RAM
                + "GB, storage=" + storage + "GB]"
                + " -- "
                + "PeripheralDevice [" + ((peripheralDevice==null)?"null":peripheralDevice.toString())
                + "]";
    }

    public static class ComputerBuilder {
        Computer c=new Computer();
        public ComputerBuilder setCPU(String CPU) {
            c.CPU = CPU;
            return this;
        }

        public ComputerBuilder setGPU(String GPU) {
            c.GPU = GPU;
            return this;
        }

        public ComputerBuilder setRAM(int RAM) {
            c.RAM = RAM;
            return this;
        }

        public ComputerBuilder setStorage(int storage) {
            c.storage = storage;
            return this;
        }
        public ComputerBuilder setPeripheralDevice(String indicator,String mouse,String keyboard){
            c.peripheralDevice=new PeripheralDevice(indicator,mouse,keyboard);
            return this;
        }
        public Computer build() {
            return c;
        }
    }
}
class PeripheralDevice{
    private String indicator;
    private String mouse;
    private String keyboard;
//    public PeripheralDevice(){}
    public PeripheralDevice(String indicator, String mouse, String keyboard){
        this.indicator=indicator;
        this.mouse=mouse;
        this.keyboard=keyboard;
    }

    @Override
    public String toString() {
        return "PeripheralDevice{" +
                "indicator='" + indicator + '\'' +
                ", mouse='" + mouse + '\'' +
                ", keyboard='" + keyboard + '\'' +
                '}';
    }
}
